package com.example.springbootsenior.MapStruct;

import com.example.springbootsenior.MapStruct.dto.CarDTO;
import com.example.springbootsenior.MapStruct.dto.EngineDTO;
import com.example.springbootsenior.MapStruct.po.Car;
import com.example.springbootsenior.MapStruct.po.Engine;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 注意这个包是org.mapstruct
 * 功能描述:
 *
 * @author: 李明杰
 * @date: 2021/11/25 22:05
 */
@Mapper(componentModel = "spring")
public interface CarMap {
    @Mapping(source = "engine.horsePower", target = "horsePower")
    @Mapping(source = "engine.fuel", target = "fuel")
    @Mapping(source = "make", target = "manufacturer")
    @Mapping(source = "numberOfSeats", target = "seatCount")
    @InheritInverseConfiguration
//可以实现互相转换
    CarDTO carToCarDto(Car car);

    EngineDTO engineToEngineDTO(Engine engine);


}
